'Anesthesia Requirement Script  
Option Strict Off
imports System
imports System.Collections
imports PHSRAG.Insight21.Humans
imports PHSRAG.Insight21.BusinessObjects
imports FormsManagement = PHSRAG.Insight21.FormsManagement
imports CDS = PHSRAG.Insight21.CDS

module Script
	sub Main()
		Dim labelAnswers as ArrayList = questAnswer.GetAnswers("Label")

		if labelAnswers.Count > 0 then
			questAnswer.Name = labelAnswers(0).Value
			questAnswer.Save( connectionString )
		end if

        ' Set the answer to Anesthesia on the std app to checked, since we''re running req script here
        for each qa as FormsManagement.QuestionnaireAnswer in currentProtVersion.QuestionnaireAnswers
            if qa.Name = "Standard Application" then
                Dim AnesAgentAnswers as ArrayList = qa.GetAnswers("AnesAgent")
                if AnesAgentAnswers.Count > 0 then
                    AnesAgentAnswers(0).Value = "ANES"
                else
					dim answer as new FormsManagement.Answer(cachePolicy)
					answer.Name = "AnesAgent"
					answer.Value = "ANES"
					answer.QuestionnaireAnswerId = qa.Id
					qa.Answers.Add(answer)
				end if
				qa.Save(connectionString)
            end if
        next
	end sub  
end module